//
//  MainChatView.m
//  BaiYing_Thinker
//
//  Created by 鹏 朱 on 15/10/29.
//  Copyright (c) 2015年 XKJH. All rights reserved.
//

#import "MainChatView.h"
#import "SHorizontalView.h"

@interface MainChatView()

@end

@implementation MainChatView

- (void)dealloc {

}

+(id)createWithFrame:(CGRect)frame ds:(NSMutableArray*)ds{
    
    MainChatView* v = [[self alloc] initWithFrame:frame ds:ds];
    return v;
}

-(id)initWithFrame:(CGRect)frame ds:(NSMutableArray*)ds{
    
    self = [super initWithFrame:frame];
    if (self) {
        SHorizontalView* shv = [[SHorizontalView alloc] initWithFrame:frame];
        svHorizontal = shv;
        shv.ds = ds;
        [self addSubview:shv];
    }
    return self;
}

- (NSIndexPath *)getCurIndexPath {
    
    return [svHorizontal getCurIndexPath];
}

-(void)setCurIndexPath:(NSIndexPath *)aCurIndexPath{

    if ([self getCurIndexPath] != aCurIndexPath) {
        _curIndexPath = aCurIndexPath;
        svHorizontal.curIndexPath = _curIndexPath;
    }
}

-(void)setCurIndexPath:(NSIndexPath *)aCurIndexPath openAnimator:(BOOL)openAnimator {

    if ([self getCurIndexPath] != aCurIndexPath) {
        _curIndexPath = aCurIndexPath;
        svHorizontal.isScrollToBottom = _isScrollToBottom;
        [svHorizontal setCurIndexPath:_curIndexPath openAnimator:openAnimator];
    } else {
        
        //收到机器人的消息滚动到最下面
        if (openAnimator && _isScrollToBottom) {
            svHorizontal.isScrollToBottom = _isScrollToBottom;
            [svHorizontal setCurIndexPath:_curIndexPath openAnimator:openAnimator];
        }
    }
}

- (void)setDataSource:(NSArray *)dataSource {
    
    svHorizontal.ds = dataSource;
}

#pragma mark - 刷新
- (void)reloadData {
    
    [svHorizontal reloadData];
}

- (void)reloadDataAtIndex:(NSUInteger)index {
    
    [svHorizontal reloadDataAtIndex:index];
}

- (void)reloadDataAtIndexPath:(NSIndexPath *)indexPath {
    
    [svHorizontal reloadDataAtIndexPath:indexPath];
}

@end
